<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"   prefix="fmt"%>
<%@ include file="index.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="favicon.ico" >
    <link rel="Shortcut Icon" href="favicon.ico" />

    <title>主页</title>
    <meta name="keywords" content="耶回收">
    <meta name="description" content="耶回收">
</head>
<body>

<!--_表格--开始-->
<section class="Hui-article-box">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>
        订单管理
        <span class="c-gray en">&gt;</span>
        租赁商品订单
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <div class="Hui-article">
        <article class="cl pd-20">
            <div class="text-c">
            <form action="zldd" method="post">
				<span class="select-box inline">
				<select name="order.status" class="select">
					<option value="0" >订单状态</option>
					<option value="1" <c:if test="${vo.order.status==1}">selected="selected"</c:if>>未支付</option>
					<option value="2" <c:if test="${vo.order.status==2}">selected="selected"</c:if>>已支付</option>
				</select>
				</span>
                日期范围：	 
                <input type="date" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" name="order.startdate" class="input-text Wdate" style="width:160px;"  value="${onetime}">
				-
				<input type="date" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" name="order.enddate" class="input-text Wdate" style="width:160px;" value="${endtime}">
                <input type="text" name="user.phone" id="" placeholder="请输入手机号码" style="width:150px" class="input-text" value="${vo.user.phone}">
                <input type="text" name="order.oid"  id="" placeholder="请输订单号码"	style="width:140px" class="input-text" value="${vo.order.oid}">

                <i class="Hui-iconfont">&#xe665;</i><input type="submit" class="btn btn-success" value="搜索" id="" name="">
                </form>
            </div>
            <div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l">
				<!-- <a class="btn btn-primary radius" data-title="添加资讯" _href="article-add.html" onclick="article_add('添加资讯','article-add.html')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加资讯</a> -->
				<shiro:hasPermission name="order"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a></shiro:hasPermission>
				</span>
                <span class="r">共有<strong>${mv.total}</strong>条 数据</span>
            </div>
            <div class="mt-20">
                <table class="table table-border table-bordered table-bg table-hover table-sort">
                    <thead>
                    <tr class="text-c">
                    	<th width="25"><input type="checkbox" name="" value=""></th>
                        <th width="90">订单编号</th>            
                        <th width="80">用户电话</th>
                        <th width="120">购买时间</th>
                        <th width="120">发货地址</th>
                        <th width="75">订单状态</th>
                        <th width="60">商品状态</th>
                        <th width="75">订单价格</th>
                        <th width="75">运单号码</th>
                        <shiro:hasPermission name="order">
                        <th width="60">操作</th>
                        </shiro:hasPermission>
                    </tr>
                    </thead>
                    <tbody id="tb">
                    <c:forEach items="${mv.list }" var="ou" varStatus="s"> 
                    <tr class="text-c">
                    	<td ><input type="checkbox" value="${ou.order.oid}" name=""></td>		
                        <td><a style="color: blue;" onclick="zld_edit('修改详情','zloedit?oid=${ou.order.oid}')">${ou.order.oid}</a></td>
                        <td>${ou.user.phone}</td>
                        <td><fmt:formatDate value="${ou.order.createtime}" pattern="yyyy-MM-dd"/></td>                   
                        <td><a style="color: blue;" onclick="zld_edit('修改地址','zldedit?uid=${ou.address.uid}')">${ou.address.state}${ou.address.city}${ou.address.district}${ou.address.address}</a></td>
                        <td class="td-status"><span class="label label-default radius">租赁订单</span></td>
                        <td class="td-status">
	                        <c:if test="${ou.order.status==1}">
	                        	<span class="label label-default radius">未付款</span>
	                        </c:if>
	                        <c:if test="${ou.order.status==2}">
	                        	<span class="label label-primary radius">已付款</span>
	                        </c:if>
                        </td>
                        <td>
	                        <a style="color: blue;" onclick="zld_edit('修改价格','payedit?oid=${ou.order.oid}')">
	                        <c:if test="${ou.order.payment!=null}">
	                        	${ou.order.payment}
	                        </c:if>
	                        <c:if test="${ou.order.payment==null}">
	                        	 +  
	                        </c:if>
                        </a>
                        <td>
	                        <a style="color: blue;" onclick="zld_edit('修改快递','zlkedit?oid=${ou.order.oid}')">
	                        <c:if test="${ou.order.logisticCode!=null}">
	                        	${ou.order.logisticCode}
	                        </c:if>
	                        <c:if test="${ou.order.logisticCode==null}">
	                        	 +  
	                        </c:if>
                        </a>
                        </td>
                        <shiro:hasPermission name="order">
                        <td class="f-14 td-manage">
                            <a style="text-decoration:none" class="ml-5" onClick="article_del('${ou.order.oid}')" href="javascript:;" title="删除">
                            	<i class="Hui-iconfont">&#xe6e2;</i>
                            </a>
                        </td>
                        </shiro:hasPermission> 
                    </tr>
                    </c:forEach>
                    </tbody>
                </table>
            		<th colspan="12"><p>当前第[${mv.pageNum}]页     共${mv.pages}页</p>
        				<a href="zldd?pageNum=1&user.phone=${vo.user.phone}&order.status=${vo.order.status}&order.oid=${vo.order.oid}&order.startdate=${onetime}&order.enddate=${endtime}">首页</a>
        				<c:if test="${mv.pageNum > 1 }">
       						<a href="zldd?pageNum=${mv.prePage}&user.phone=${vo.user.phone}&order.status=${vo.order.status}&order.oid=${vo.order.oid}&order.startdate=${onetime}&order.enddate=${endtime}">上一页</a>
       					</c:if>
       					<c:if test="${mv.pageNum <= 1 }">
							<a class="right">上一页</a>
						</c:if>
        				<c:if test="${mv.pageNum < mv.pages}">
        					<a href="zldd?pageNum=${mv.nextPage}&user.phone=${vo.user.phone}&order.status=${vo.order.status}&order.oid=${vo.order.oid}&order.startdate=${onetime}&order.enddate=${endtime}">下一页</a>
        				</c:if>
        				<c:if test="${mv.pageNum >= mv.pages}">
							<a class="right">下一页</a>
						</c:if>
        				<a href="zldd?pageNum=${mv.pages}&user.phone=${vo.user.phone}&order.status=${vo.order.status}&order.oid=${vo.order.oid}&order.startdate=${onetime}&order.enddate=${endtime}">尾页</a>
        		    </th>
            </div>
        </article> 	
    </div>
</section>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
   
    /*资讯-删除*/
    function article_del(oid){
        layer.confirm('确认要删除吗？',{ btn: ["确定","取消"] },function(index){
            $.ajax({
                type: 'POST',
                url: 'delzlo',
                data:{"oid":oid},
                dataType: 'json',
                success: function(val){
                	layer.close(index);
                	alert("删除成功");
                	window.location.href = window.location.href;                	
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }
    
    function zld_edit(title,url){
        var index = layer.open({
            type: 2,
            anim:3,
            title: title,
            area: [600+'px',300 +'px'],
            shade:0.2,
            content:url,
            end:function(){
            window.location.reload();
            }
        });
        
    }

    /*批量删除*/
    function datadel(){
 	  console.log("-----进入批量删除的方法------");
 	  var tds = new Array();
        //获取所有的tr标签元素集合
 	   tds=document.getElementById("tb").getElementsByTagName("tr");
 		  var td_s = new Array();
 		 
 		  for(var i=0;i<tds.length;i++){
 		  var tdc =tds[i].getElementsByTagName("td")[0].getElementsByTagName("input")[0];
 		  var tdcheck =$(tdc);
 		  console.log(tdcheck.is(":checked"));
 		  if(tdcheck.is(":checked")){
 		    //如果td被选中 则td的id值放入数组中
 			td_s.push(tdcheck.val());
 		    
 		 } 
 		  } 
 	   //判断是否有被选中删除的记录 
 	   if(td_s.length>0){
 		  console.log(td_s);
 		   //发出批量删除ajax 删除请求
 		   layer.confirm('确认要删除吗？',{ btn: ["确定","取消"] },function(index){
 	           $.ajax({
 	               type: 'POST',
 	               url: 'deleteZLin',
 	               data:{"td_s":td_s},
 	               dataType: 'json',
 	               success: function(val){
 	               	layer.close(index);
 	               layer.msg("删除成功",{icon:1,time:2000});
 	               	window.location.href = window.location.href;                	
 	               },
 	               error:function(data) {
 	                   console.log(data.msg);
 	               },
 	           });
 	       });
 	   }else{ 
 		   
 		   layer.msg("请选择要删除的数据！",{time:2000});
 		 
 	   }
 	   
    } 
</script>
</body>
</html>